package com.wuchao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wuchao.entity.Vehicle;
import com.wuchao.mapper.VehicleMapper;
import com.wuchao.service.VehicleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wuchao
 * @since 2022-08-04
 */
@Service
public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> implements VehicleService {
    @Resource
    VehicleMapper vehicleMapper;
    @Override
    public List<Vehicle> findVehicleAndTtype() {
        return vehicleMapper.findVehicleAndTtype();
    }

    @Override
    public Page<Vehicle> findVehicleAndTtypeByName(int currentPage, int pageSize, String name) {
        Page<Vehicle> vehiclePage = new Page<>(currentPage,pageSize);
        QueryWrapper<Vehicle> vehicleQueryWrapper = new QueryWrapper<>();
        QueryWrapper<Vehicle> vname = vehicleQueryWrapper.like("vname", name);
        Page<Vehicle> vehiclePage1 = vehicleMapper.selectPage(vehiclePage, vname);
        return vehiclePage1;
    }
}
